package org.item.customer.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.item.common.bean.Customers;

import org.item.common.bean.Product;
import org.item.common.service.ICustomerService;

import org.item.customer.mapper.CustomerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerService implements ICustomerService {
   @Autowired
   CustomerMapper customerMapper;


    @Override
    public Customers insert(Customers customers) {
        customerMapper.insert(customers);
        Customers result=this.getById(customers.getId());
        return result;
    }

    @Override
    public Customers update(Customers customers) {
        customerMapper.updateById(customers);
        Customers result=this.getById(customers.getId());
        return result;
    }

    @Override
    public int delete(Integer id) {
        int num=customerMapper.deleteById(id);;
        return num;
    }

    @Override
    public Customers getById(Integer id) {
        Customers result=customerMapper.selectById(id);
        return result;
    }

    @Override
    public IPage<Customers> getListByPage(IPage page, Customers customers) {
        Wrapper wrapper=new QueryWrapper(customers);
        IPage result=customerMapper.selectPage(page,wrapper);
        return result;
    }

    @Override
    public List<Customers> getList(Customers customers) {
        Wrapper wrapper=new QueryWrapper(customers);
        List<Customers> result=customerMapper.selectList(wrapper);
        return result;
    }
}
